import random

secret_number = random, random.randint(1, 100)
max_attempts = 5
attempts = 0

print("=== 猜数字游戏(1-100) ===")
print(f"你有{max_attempts}次机会")

while attempts < max_attempts:


while attempts < max_attempts:
    guess = int(input(f"第{attempts + 1}此猜数:"))

    if guess == secret_number:
        print(f"恭喜!你用了{attempts + 1}次猜中了数字{secret_number}")
        break
    elif guess < secret_number:
        print("猜小了!")
    else:
        print("猜大了")
    attempts += 1
    remaining = max_attempts - attempts
    if remaining > 0:
        print(f"剩余机会: {remaining}")
    else:
        print(f"游戏结束！正确答案是: {secret_number}")
play_again= input("\n再玩一次?(y/n):").lower()
if play_again == 'y':
    exec(open(__file__).read())




total = 0
num = 0

while num <= 100:
    if num % 2 != 0:
        total += num
    num +=1
print(f"1~100的奇数和:{total}")


total = 0
current = 1
print("累加过程:")

while current <= 100:
    print(f"+{current}", end=" ")
    total += current
    current += 2
    if current <= 100:
        print("→",end=" ")

print(f"\n最终结果:{total}")
